package com.ushio.gougouwangguo.service.impl;

import com.ushio.commonmodule.utils.JwtUtil;
import com.ushio.gougouwangguo.entity.mysql.UserMaterials;
import com.ushio.gougouwangguo.entity.qo.UserMaterialsByIdQo;
import com.ushio.gougouwangguo.entity.vo.UserMaterialsVo;
import com.ushio.gougouwangguo.mapper.UserMaterialsMapper;
import com.ushio.gougouwangguo.service.IUserMaterialsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户资源表 服务实现类
 * </p>
 *
 * @author 张文凯
 * @since 2025-09-23
 */
@Service
public class UserMaterialsServiceImpl extends ServiceImpl<UserMaterialsMapper, UserMaterials> implements IUserMaterialsService {
    @Autowired
    UserMaterialsMapper userMaterialsMapper;

    @Override
    public List<UserMaterialsVo> getUserMaterials(Long userId) {

        List<UserMaterialsVo> userMaterials = userMaterialsMapper.getUserMaterials(userId);

        return userMaterials;
    }

    @Override
    public List<UserMaterialsVo> getUserMaterialsByid(UserMaterialsByIdQo userMaterialsByIdQo) {
        List<Long> ids = userMaterialsByIdQo.getIds();
        Long userId = userMaterialsByIdQo.getUserId();
        List<UserMaterialsVo> userMaterials =  userMaterialsMapper.getUserMaterialsByid(userId,ids);
        return userMaterials;
    }

    @Override
    public UserMaterialsVo getRoom() {

        Long userId = JwtUtil.parseUser().getUserId();

        return userMaterialsMapper.getRoom(userId);
    }
}
